package com.chennan.javabase.domain.juc.forkjoin;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;

/**
 * @author chennan
 * @create 2022-01
 */
public class ForkJoinTest {
    public static void main(String[] args) throws InterruptedException, ExecutionException {
        Long start = System.currentTimeMillis();
        ForkJoinPool forkJoinPool = new ForkJoinPool(8);
        ForkJoinTask<Long> task = new ForkJoinDemo(0L,10000000L);
//        forkJoinPool.execute(task); 异步
        ForkJoinTask<Long> submit = forkJoinPool.submit(task);
        Long aLong = submit.get();
        System.out.println(aLong+"执行完毕"+(System.currentTimeMillis()-start));
    }
}
